: synapse.mod

TITLE Synaptic conductances of CA3 neurons

COMMENT
-------------------------------------------------------------------------
    synaptic current modeled with monoexponential rise 
    and decay conductances defined by:

        i = g * (v-e), 
    
    where i is current in nA, g is conductance in microhms, 
    v is membrane potential (in mV) and e is the reversal potential 
    of the synapse (in mV)

        g = 0 for t < tonset and
        g = ( (1-exp(-(t-tonset)/tau0)*(exp(-(t-tonset)/tau1))) 
        for t > tonset

    the function is normalized to time of the peak, so that the gmax is the 
    peak of the conductance.
-------------------------------------------------------------------------
ENDCOMMENT


NEURON {
    POINT_PROCESS synapse
    RANGE gmax
    RANGE tonset, tau0, tau1, e_rev, i
    NONSPECIFIC_CURRENT i
}

UNITS {
        (nA) = (nanoamp)
        (mV) = (millivolt)
        (uS) = (micromho)
}

PARAMETER {
    tonset = 0.0 (ms)
    tau0 =  0.3 (ms)
    tau1 =  5.0 (ms)
    gmax =  0.0 (uS)
    e_rev = 0.0 (mV)
}

ASSIGNED {
    i   (nA)
    g   (uS)
    v   (mV)
}

FUNCTION biexponential(x (ms)) {
    biexponential = (1-exp(-(x-tonset)/tau0))*(exp(-(x-tonset)/tau1))
}

: Tpeak was solved analytically with Sage 
: Tpeak is a as function of tau0, tau1 and tonset

LOCAL norm 

FUNCTION conductance(x (ms)) (uS) { 
    LOCAL tpeak
    tpeak = tau0*log(tau1/tau0 + 1) + tonset
    : function is normalized to tpeak
    norm = biexponential(x)/biexponential(tpeak)

    if (x < tonset) {
        conductance = 0
    }
    else {
        : now conductance is gmax
        conductance = gmax*norm
    }
}

: This mechanism will not be compatiable with variable time steps
BREAKPOINT {
    g = conductance(t)
    i = g*(v - e_rev)
}
